home *** CD-ROM | disk | FTP | other *** search
- /* sum of divisors of n, n not included */
- int am_sumdivisors(int n)
- {
- int Kleng,x=1;
- int Grouss=n;
- int Sum=n+1;
-
- if(n<0)
- n = -n;
-
- if(n < 2)
- return 0;
-
- if (n&1){
- Kleng=3;
- x=2;
- }
- else
- Kleng=2;
-
- while(Kleng<Grouss)
- {
- if((n % Kleng) == 0)
- {
- Sum += Kleng;
- Grouss = n / Kleng;
- if(Kleng != Grouss)
- Sum += Grouss;
- }
- Kleng=Kleng+x;
- }
-
- return Sum - n;
- }